import Vue from 'vue'
import Router from 'vue-router'
import Index from '@/page/Index'

import Welcome from '@/page/wallet/Welcome'


import EthCreateWallet from '@/page/wallet/eth/EthCreateWallet'
import EthImportWallet from '@/page/wallet/eth/EthImportWallet'
import EthWalletInfo from '@/page/wallet/eth/EthWalletInfo'
import EthUpdatePwd from '@/page/wallet/eth/EthUpdatePwd'
import EthReceiptCode from '@/page/wallet/eth/EthReceiptCode'
import EthSaveMemonic from '@/page/wallet/eth/EthSaveMemonic'

import CoinList from '@/page/eth/CoinList'
import Transaction from '@/page/eth/Transaction'
import TransactionTo from '@/page/eth/TransactionTo'
import TransactionInfo from '@/page/eth/TransactionInfo'
import TransactionERC from '@/page/eth/TransactionERC'
import TransactionToERC from '@/page/eth/TransactionToERC'
import Scan from '@/page/eth/Scan'
import Pay from '@/page/eth/Pay'

import Market from '@/page/market/Market'
import AddMarket from '@/page/market/AddMarket'
import MarketInfo from '@/page/market/MarketInfo'

import My from '@/page/my/My'
import MyWallet from '@/page/my/MyWallet'
import TransactionHistory from '@/page/my/TransactionHistory'
import MyTransactionInfo from '@/page/my/MyTransactionInfo'
import MyMessage from '@/page/my/MyMessage'
import MyContact from '@/page/my/MyContact'
import AboutUs from '@/page/my/AboutUs'
import Invite from '@/page/my/Invite'
import UserAgreement from '@/page/my/UserAgreement'

import Exchange from '@/page/exchange/Exchange'

import store from "../store"


Vue.use(Router)

let route = new Router({
  // mode: 'history',
  routes: [
    {
      path: '/',
      name: 'Index',
      component: Index
    },
    {
      path: '/welcome',
      name: 'Welcome',
      component: Welcome
    },

    //以太坊钱包
    {
      path: '/ethCreateWallet',
      name: 'EthCreateWallet',
      component: EthCreateWallet
    },
    {
      path: '/ethImportWallet',
      name: 'EthImportWallet',
      component: EthImportWallet
    },
    {
      path: '/ethWalletInfo',
      name: 'EthWalletInfo',
      component: EthWalletInfo
    },
    {
      path: '/ethUpdatePwd',
      name: 'EthUpdatePwd',
      component: EthUpdatePwd
    },
    {
      path: '/ethReceiptCode',
      name: 'EthReceiptCode',
      component: EthReceiptCode
    },
    {
      path: '/ethSaveMemonic',
      name: 'EthSaveMemonic',
      component: EthSaveMemonic
    },
    //以太坊钱包逻辑
    {
      path: '/coinList',
      name: 'CoinList',
      component: CoinList
    },
    {
      path: '/transaction',
      name: 'Transaction',
      component: Transaction
    },
    {
      path: '/transactionTo',
      name: 'TransactionTo',
      component: TransactionTo
    },
    {
      path: '/transactionInfo',
      name: 'TransactionInfo',
      component: TransactionInfo
    },
    {
      path: '/transactionERC',
      name: 'TransactionERC',
      component: TransactionERC
    },
    {
      path: '/transactionToERC',
      name: 'TransactionToERC',
      component: TransactionToERC
    },
    {
      path: '/market',
      name: 'Market',
      component: Market
    },
    {
      path: '/addMarket',
      name: 'AddMarket',
      component: AddMarket
    },
    {
      path: '/marketInfo',
      name: 'MarketInfo',
      component: MarketInfo
    },
    {
      path: '/exchange',
      name: 'Exchange',
      component: Exchange
    },
    {
      path: '/my',
      name: 'My',
      component: My
    },
    {
      path: '/myWallet',
      name: 'MyWallet',
      component: MyWallet
    },
    {
      path: '/transactionHistory',
      name: 'TransactionHistory',
      component: TransactionHistory
    },
    {
      path: '/myTransactionInfo',
      name: 'MyTransactionInfo',
      component: MyTransactionInfo
    },
    {
      path: '/myMessage',
      name: 'MyMessage',
      component: MyMessage
    },
    {
      path: '/myContact',
      name: 'MyContact',
      component: MyContact
    },
    {
      path: '/scan',
      name: 'Scan',
      component: Scan
    },
    {
      path: '/pay',
      name: 'Pay',
      component: Pay
    },
    {
      path: '/aboutUs',
      name: 'AboutUs',
      component: AboutUs
    },
    {
      path: '/invite',
      name: 'Invite',
      component: Invite
    },
    {
      path: '/userAgreement',
      name: 'UserAgreement',
      component: UserAgreement
    }
  ]
})

route.beforeEach((to,from,next)=>{
  store.commit(
    'changeNav',
    false
  )
  if(to.path === '/market' || to.path === '/' || to.path === '/my' || to.path === '/exchange') {
    store.commit(
      'changeNav',
      true
    )
  }else{
    store.commit(
      'changeNav',
      false
    )
  }
  next();
})

export default route
